package main

import (
	"github.com/gin-gonic/gin"
	"log"
)

func Logining(c *gin.Context) {
	var logPara struct {
		Username string `json:"username"`
		Password string `json:"password"`
	}
	if err := c.Bind(&logPara); err != nil {
		log.Println(err)
		c.String(503, "%s", "error")
		return
	}
	err, status := checkUser(logPara.Username, logPara.Password)
	if err != nil && status == 0 {
		c.String(403, "%s", "user do not exist")
		return
	}
	if err != nil && status == 1 {
		c.String(404, "%s", "password do not exist")
	}
	c.String(200, "%s", "login success")
}